﻿Imports System.IO
Public Class HTForm

    Private Shared Function GetCnnStrFromFile(ByVal pFileSpec As String) As String
        Dim mPassFromFile As String = ""
        Dim mCnnStr As String = ""
        'Dim mFileName As String = Application.StartupPath & "\VKPass.txt"
        Try
            Dim sr As StreamReader = New StreamReader(pFileSpec)
            Dim line As String
            Do
                line = sr.ReadLine()
                If Not IsNothing(line) Then
                    If line.IndexOf("Provider") > -1 Then
                        mCnnStr = line
                        Exit Do
                    End If
                End If
            Loop Until line Is Nothing

            sr.Close()
        Catch E As Exception
        End Try

        Return mCnnStr
    End Function

    Private Sub QuảnLýCápToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuảnLýCápToolStripMenuItem.Click
        Dim frm As New frmThietBi_Tram()
        frm.ShowDialog()
    End Sub

    Private Sub HTForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        myConnStr = GetCnnStrFromFile(Application.StartupPath & "\data.udl")
        'myConnStr = Global.ThietBi.My.MySettings.Default.ThietBiConnectionString
        'MITI.BaseDB.g_ConnectStr = myConnStr 'Global.ThietBi.My.MySettings.Default.ThietBiConnectionString
        MITI.BaseDB.g_ConnectStr = MITI.BaseDB.GetConnectStrFromFile(Application.StartupPath + "\data.udl")
        Dim lblCSDL As String = MITI.BaseDB.LayGiaTriThanhPhan("Initial Catalog")
        Dim lblServer As String = MITI.BaseDB.LayGiaTriThanhPhan("Data Source")
    End Sub

    Private Sub TreeViewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TreeViewToolStripMenuItem.Click
        Dim frm As New frmTestControl
        frm.ShowDialog()
    End Sub

    Private Sub QuảnLýVibaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuảnLýVibaToolStripMenuItem.Click
        Dim frm As New frmTestControl
        frm.ShowDialog()
    End Sub
End Class